package com.bwie.common.domain.request;

import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class DocInfoReq {

    //索引名称
    private String indexName;

    //文档数组
    private List<Map<String,Object>> datas;

    //是否需要指定文档ID
    private boolean isNeeId=false;

    //文档Id指定字段
    private String idField;

    public static void main(String[] args) {
        DocInfoReq docInfoReq = new DocInfoReq();
        docInfoReq.setIndexName("indexName");
        docInfoReq.setNeeId(true);
        docInfoReq.setIdField("pid");
        //构建文档数据
       List<Map<String, Object>> datas = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            HashMap<String, Object> data = new HashMap<>();
            data.put("pid",i);
            data.put("name","name"+i);
            data.put("age",i+5);
            datas.add(data);
        }
        docInfoReq.setDatas(datas);
        System.out.println(JSONObject.toJSONString(docInfoReq));

    }



}
